<template>
  <a-spin :spinning="confirmLoading">
    <j-form-container :disabled="false">
      <a-form-model ref="form" :model="model" :rules="validatorRules" slot="detail">
        <a-row :gutter="48">
          <a-col :span="12">
            <a-form-model-item label="手机号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="mobile">
              <a-input :disabled="formDisabled" v-model="model.mobile" placeholder="请输入手机号"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="紧急联系人方式" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="fixedTel">
              <a-input :disabled="formDisabled" v-model="model.fixedTel" placeholder="请输入紧急联系人方式"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="电子邮件" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="email">
              <a-input :disabled="formDisabled" v-model="model.email" placeholder="请输入电子邮件"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="邮政编码" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="postCode">
              <a-input :disabled="formDisabled" v-model="model.postCode" placeholder="请输入邮政编码"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="身份证地址" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="idCardAddress">
              <a-input :disabled="formDisabled" v-model="model.idCardAddress" placeholder="请输入身份证地址"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="现居地址" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="currentAddress">
              <a-input :disabled="formDisabled" v-model="model.currentAddress" placeholder="请输入现居地址"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="户籍地址" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="householdAddress">
              <a-input :disabled="formDisabled" v-model="model.householdAddress" placeholder="请输入户籍地址"  ></a-input>
            </a-form-model-item>
          </a-col>
        </a-row>
      </a-form-model>
    </j-form-container>
  </a-spin>
</template>

<script>

  import { httpAction, getAction } from '@/api/manage'
  import { validateDuplicateValue } from '@/utils/util'

  export default {
    name: 'ErpHrApplyContactInfoForm',
    components: {
    },
    props: {
      //表单禁用
      disabled: {
        type: Boolean,
        default: false,
        required: false
      }
    },
    data () {
      return {
        model:{
         },
        labelCol: {
        },
        wrapperCol: {
          xs: { span: 24 },
          sm: { span: 24 },
        },
        confirmLoading: false,
        validatorRules: {
          mobile: [{ required: true, message: '请输入手机号', trigger: 'blur' }],
          fixedTel: [{ required: true, message: '请输入紧急联系人方式', trigger: 'blur' }],
          email: [{ required: true, message: '请输入电子邮件', trigger: 'blur' }],
          idCardAddress: [{ required: true, message: '请输入身份证地址', trigger: 'blur' }],
          currentAddress: [{ required: true, message: '请输入现居地址', trigger: 'blur' }],
          householdAddress: [{ required: true, message: '请输入户籍地址', trigger: 'blur' }],
        },
        url: {
          add: "/api/erp/hr/apply/erpHrApplyContactInfo/add",
          edit: "/api/erp/hr/apply/erpHrApplyContactInfo/edit",
          queryById: "/api/erp/hr/apply/erpHrApplyContactInfo/queryById"
        }
      }
    },
    computed: {
      formDisabled(){
        return this.disabled
      },
    },
    created () {
       //备份model原始值
      this.modelDefault = JSON.parse(JSON.stringify(this.model));
    },
    methods: {
      add () {
        this.edit(this.modelDefault);
      },
      edit (record) {
        this.$refs.form.resetFields();
        this.model = Object.assign({}, record);
        this.visible = true;
      },
      submitForm () {
        const that = this;
        // 触发表单验证
        this.$refs.form.validate(valid => {
          if (valid) {
            // that.confirmLoading = true;
            // let httpurl = '';
            // let method = '';
            // if(!this.model.id){
            //   httpurl+=this.url.add;
            //   method = 'post';
            // }else{
            //   httpurl+=this.url.edit;
            //    method = 'put';
            // }
            // httpAction(httpurl,this.model,method).then((res)=>{
            //   if(res.success){
            //     that.$message.success(res.message);
            //     that.$emit('ok');
            //   }else{
            //     that.$message.warning(res.message);
            //   }
            // }).finally(() => {
            //   that.confirmLoading = false;
            // })
            this.$emit('ok',this.model)
          }

        })
      },
    }
  }
</script>
